﻿Imports System.ComponentModel
Imports DevExpress.XtraEditors.Registrator
Imports DevExpress.XtraEditors.Controls

<UserRepositoryItem("Register")> _
Public Class RepositoryItemButtonRichTextEditExt
    Inherits RepositoryItemButtonEdit
    Implements IDisposable

    Shared Sub New()
        Register()
    End Sub
    Public Sub New()
        'Me.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor
    End Sub

    Private _RichRI As New RepositoryItemRichTextEdit()

    Public Property RichEdit() As RepositoryItemRichTextEdit
        Get
            Return _RichRI
        End Get
        Set(ByVal value As RepositoryItemRichTextEdit)
            _RichRI = value
        End Set
    End Property

    Public Overrides Property TextEditStyle() As TextEditStyles
        Get
            Return TextEditStyles.DisableTextEditor
        End Get
        Set(ByVal value As TextEditStyles)

        End Set
    End Property

    Private _text As String

    Public Property Text() As String
        Get
            Return _text
        End Get
        Set(ByVal value As String)
            _text = value
            If (Not _text = value) Then
                _text = value
                OnPropertiesChanged()
            End If
        End Set
    End Property

    Friend Const EditorName As String = "RepositoryItemButtonRichTextEditExt"

    Public Shared Sub Register()
        EditorRegistrationInfo.Default.Editors.Add(New EditorClassInfo(EditorName, GetType(ButtonRichTextEditExt), GetType(RepositoryItemButtonRichTextEditExt), GetType(RichTextButtonEditViewInfo), New RichTextButtonEditPainter(), True))
    End Sub
    Public Overrides ReadOnly Property EditorTypeName() As String
        Get
            Return EditorName
        End Get
    End Property

    Public Overrides Sub Assign(ByVal item As RepositoryItem)
        MyBase.Assign(item)

        Dim myri As RepositoryItemButtonRichTextEditExt = TryCast(item, RepositoryItemButtonRichTextEditExt)
        myri.RichEdit.AllowHtmlDraw = DevExpress.Utils.DefaultBoolean.True
        myri.RichEdit.DocumentFormat = DevExpress.XtraRichEdit.DocumentFormat.Rtf
        myri.RichEdit.OptionsExport.Html.EmbedImages = True
        RichEdit.Assign(myri.RichEdit)
    End Sub

End Class
